package com.springboot.study.service;

import com.springboot.study.config.InitDataService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author: guodong
 * @Date: 2021/10/9 9:38
 * @Version: 1.0
 * @Description:
 */
@Component
public class TestBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof InitDataService){
            System.out.println("马上开始初始化TobyBean了，注意下");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof InitDataService){
            System.out.println("初始化完成TobyBean了，注意下");
        }
        return bean;
    }


}
